package com.alibaba.citrus.ots.common.log;

import lombok.Data;

/**
 * @author: qiaojiange
 * @create: 2021/10/02
 * @Description 访问日志体
 */
@Data
public class AccessLogBody {
    /**
     * 返回对象主内容
     */
    String resultBody;

    /**
     * 当前处理结果是否成功：标识业务调用结果
     */
    Boolean success;

    /**
     * 错误码
     */
    String errorCode;
    /**
     * 错误信息
     */
    String errorMsg;
    /**
     * 入参
     */
    String argsBody;

    public static AccessLogBody of(String argsBody, String resultBody, Boolean success, String errorCode, String errorMsg) {
        AccessLogBody accessLogBody = new AccessLogBody();
        accessLogBody.setArgsBody(argsBody);
        accessLogBody.setResultBody(resultBody);
        accessLogBody.setSuccess(success);
        accessLogBody.setErrorCode(errorCode);
        accessLogBody.setErrorMsg(errorMsg);
        return accessLogBody;
    }

    /**
     * 默认出错的访问日志
     * @param argsBody 参数
     * @return
     */
    public static AccessLogBody DEFAULT_ACCESS_LOG(String argsBody) {
        AccessLogBody accessLogBody = new AccessLogBody();
        accessLogBody.setArgsBody(argsBody);
        accessLogBody.setResultBody(null);
        accessLogBody.setSuccess(false);
        accessLogBody.setErrorCode(CommonErrorCode.SYSTEM_ERROR);
        accessLogBody.setErrorMsg("系统开小差了~");
        return accessLogBody;
    }

}
